package com.usian.controller;

import com.usian.pojo.SearchItem;
import com.usian.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;


@RestController
public class SearchController {

    @Autowired
    private SearchService searchService;

    /**
     * 添加数据到索引库
     *
     * @return
     */
    @RequestMapping("importAll")
    public boolean importAll(){
        return searchService.importAll();
    }

    /**
     * 首页搜索
     *
     * @param q
     * @param page
     * @param pageSize
     * @return
     */
    @RequestMapping("list")
    public List<SearchItem> list(@RequestParam String q,
                                 @RequestParam Long page,
                                 @RequestParam Long pageSize) {
        return searchService.list(q,page,pageSize);
    }
}
